package com.you07.learn.utils;

/**
 * @ClassName: Result
 * @Author: chenguo
 * @Data: 2019年06月09日 13时24分
 * @Description:
 * @Company: 成都灵奇空间软件
 * @Version: 1.0
 */
public class Result {
    private static final ResultMessage RESULT_MESSAGE_SUCCESS = new ResultMessage(ErrorCode.SUCCESS, "成功", null, true);

    public static ResultMessage success() {
        return RESULT_MESSAGE_SUCCESS;
    }

    public static <T> ResultMessage<T> success(T data) {
        return new ResultMessage(ErrorCode.SUCCESS, data, true);
    }

    public static <T> ResultMessage<T> success(ErrorCode errorCode, T data) {
        return new ResultMessage(errorCode, data, true);
    }

    public static <T> ResultMessage<T> success(ErrorCode errorCode, String errorMsg, T data) {
        return new ResultMessage(errorCode, errorMsg, data, true);
    }

    public static ResultMessage error() {
        return new ResultMessage(ErrorCode.ERROR, false);
    }

    public static ResultMessage error(ErrorCode errorCode) {
        return new ResultMessage(errorCode, errorCode.getMsg(), null, false);
    }

    public static ResultMessage error(String errorMsg) {
        return new ResultMessage(ErrorCode.ERROR, errorMsg, null, false);
    }

    public static ResultMessage error(ErrorCode errorCode, String errorMsg) {
        return new ResultMessage(errorCode, errorMsg, null, false);
    }
}
